Marketplace Sub Domains

In a market place configuration, it is possible to have many subdomains on a single IIS website, behaving as separates websites.

IIS Setup

Point a wildcard DNS to the dedicated IP address of the website.

Do not include a host header.

Add URLRewrite rules as follows:-

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
            <rules>
                <clear />
                <rule name="Domain">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^www.eventsity.com$" negate="true" />
                        <add input="{HTTP_HOST}" pattern="^www\.([^.]+)\.([^]+)$" />
                    </conditions>
                    <action type="Rewrite" url="/_a/{C:1}/{R:0}" />
                </rule>
                <rule name="Subdomain">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^www.eventsity.com$" negate="true" />
                        <add input="{HTTP_HOST}" pattern="^([^.]+)\.eventsity\.com$" />
                    </conditions>
                    <action type="Rewrite" url="/_a/{C:1}/{R:0}" />
                </rule>
                <rule name="ASP" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{R:0}.asp" />
                </rule>
            </rules>
        </rewrite>
        <httpErrors errorMode="Detailed" />
        <defaultDocument>
            <files>
                <add value="index.asp" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

comments powered by Disqus